package com.bw.car.view

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.core.widget.addTextChangedListener
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.amap.api.maps2d.AMap
import com.amap.api.maps2d.MapView
import com.amap.api.maps2d.model.MyLocationStyle
import com.bw.base.constants.RoutePath
import com.bw.car.R
import com.bw.car.databinding.ActivityEditBinding
import com.bw.car.net.CarViewModel
import com.bw.common.view.BaseMvvmActivity


@Route(path = RoutePath.PATH_CAR_EDIT)
class EditActivity : BaseMvvmActivity<ActivityEditBinding,CarViewModel>() {

    // 车位号
    private var position:String=""

    //车辆类型
    private var type:String=""

    //车辆停车区域
    private var address:String=""

    //车辆颜色
    private var color:String=""

    //车主
    private var author:String=""

    //车牌号
    private var code:String=""

    //行驶里程
    private var km:String=""

    //备注信息
    private var desc:String=""

    private var  map: MapView ? =null

    private var  mapController: AMap? = null

    private var locationStyle: MyLocationStyle ? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        map=binding.map
        map?.onCreate(savedInstanceState)
    }

    override fun initView() {

        binding.codeIcon.setOnClickListener {

            ARouter.getInstance().build(RoutePath.PATH_CAR_EDIT_CODE).navigation()

        }

        if(null==mapController){

            mapController=map?.map

        }

        locationStyle=MyLocationStyle()

        locationStyle?.interval(2000)

        locationStyle?.myLocationType(MyLocationStyle.LOCATION_TYPE_FOLLOW)

        mapController?.setMyLocationStyle(locationStyle)

        mapController?.isMyLocationEnabled=true

    }


    override fun initData() {

    }

    override fun onDestroy() {
        super.onDestroy()
        map?.onDestroy()
    }
}